package com.quinn.json;

import cn.hutool.core.collection.ListUtil;
import cn.hutool.json.JSON;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONUtil;

import java.io.File;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * jsonReader
 *
 * @author HanQuinn
 * Date: 2023/2/20
 * Time: 10:26
 */
public class jsonReader {

    public static void main(String[] args) {
        File file = new File("C:\\Users\\周汉坤\\Desktop\\json.txt");
        try {
            JSON json = JSONUtil.readJSON(file, StandardCharsets.UTF_8);
            String jsonStr = json.toJSONString(1); // indentFactor每一级别的缩进
            List<DeptA> deptAS = JSONUtil.toList(jsonStr, DeptA.class);
            deptAS.forEach(d -> System.out.println(d.getName()));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
